// DebugPort.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <STDLIB.H>

typedef DWORD (WINAPI * lpZwQueryInformationProcess)(HANDLE, DWORD, PVOID, ULONG, PULONG);

int main(int argc, char* argv[])
{
//	printf("Hello World!\n");
	HINSTANCE hDll = NULL;
	lpZwQueryInformationProcess ZwQueryInformationProcess = NULL;
	hDll = LoadLibrary("ntdll.dll");
	if (hDll == NULL)
	{
		printf("LoadLibrary Fail\n");
		return 0;
	}
	ZwQueryInformationProcess = (lpZwQueryInformationProcess)GetProcAddress(hDll, "ZwQueryInformationProcess");
	if (ZwQueryInformationProcess == NULL)
	{
		printf("GetProcAddress Fail\n");
		return 0;
	}

	DWORD_PTR dwDebugPort = 0;
	DWORD dwRetLength = 0;
	HANDLE hProcess = GetCurrentProcess();
	ZwQueryInformationProcess(hProcess, 7, &dwDebugPort, sizeof(dwDebugPort), &dwRetLength);
	printf("DebugPort:0x%x\n", dwDebugPort);
	
	system("pause");
	return 0;
}

